package cn.edu.bupt.ch6_2.mapper;

import cn.edu.bupt.ch6_2.dto.ProductWithComments;
import cn.edu.bupt.ch6_2.entity.Product;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

public interface ProductMapper {

    public List<Product> findAll();
    public int create(Product product);
    public Product findById(@Param(value = "id") Long id);
    public int deleteById(@Param(value = "id") Long id);

    public int update(Product product);

    //一对多级联----嵌套Select查询方案示例
    public List<ProductWithComments> findByNameWithComments(@Param(value = "name") String name);
    //一对多级联----嵌套 结果映射方案示例
    public List<ProductWithComments> findByNameWithCommentsV2(@Param(value = "name") String name);

}
